using System;
using System.Data.Objects.DataClasses;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;

namespace Acme.Northwind.EFDAL
{
	internal class DBHelper
	{
		internal static IDbConnection GetConnection()
		{
			return new SqlConnection(NorthwindEntities.GetConnectionString());
		}

		internal static IDbCommand GetCommand(string commandText, CommandType commandType, IDbConnection connection)
		{
			SqlCommand cmd = new SqlCommand(commandText);
			cmd.CommandType = commandType;
			cmd.Connection = (SqlConnection)connection;
			return cmd;
		}

		internal static void AddParameter(IDbCommand cmd, string parameterName, object value)
		{
			SqlParameter sqlParam = new SqlParameter(parameterName, value);
			cmd.Parameters.Add(sqlParam);
		}

		internal static void AddReturnParameter(IDbCommand cmd)
		{
			SqlParameter sqlParam = new SqlParameter();
			sqlParam.ParameterName = "@RETURN_VALUE";
			sqlParam.Direction = ParameterDirection.ReturnValue;
			cmd.Parameters.Add(sqlParam);
		}

	}

	internal interface IEntityWithContext
	{
			NorthwindEntities Context { get; set; }
	}

}

